<?php
ini_set('display_errors',1);            //错误信息
ini_set('display_startup_errors',1);    //php启动错误信息
error_reporting(-1);                    //打印出所有的 错误信息
ini_set('error_log', dirname(__FILE__) . '/error_log.txt'); //将出错信息输出到一个文本文件
//构造函数，获取Access Token
require dirname(__FILE__).'/init.inc.php';
require_once dirname(__FILE__).'/smarty.inc.php';
require_once 'action/AcIndexAction.class.php';
global $wechatObj;
global $smarty;
$js_sdk = new JSSDK(APPID,APPSECRET,$wechatObj->access_token);
$model = new UserModel();
$action = new AcIndexAction($smarty, $js_sdk,$model);
echo "<h2>活动已结束</h2>";
/*
if(isset($_GET['code'])){
    $code = $_GET['code'];
    $result = $wechatObj->getOpenIdByCode($code);
    if(!empty($result)) {
        $current_person_openid = $result['openid'];
        if(!empty($_GET['state'])){
            $openid = $_GET['state'];
            if(strstr($current_person_openid,$openid)){ // 当前用户跟点击传进来的openid是同一个人
                header("Location:https://open.weixin.qq.com/connect/oauth2/authorize?appid=".APPID."&redirect_uri=".DOMAIN."register.php&response_type=code&scope=snsapi_base&state=$openid#wechat_redirect");
            }elseif($action->existsOpenid($openid)){// 传来openid在数据库，可以投票
                header("Location:https://open.weixin.qq.com/connect/oauth2/authorize?appid=".APPID."&redirect_uri=".DOMAIN."like.php&response_type=code&scope=snsapi_base&state=$openid#wechat_redirect");
            }else{
                // 主界面
                $action->action();
            }
        }else{// 主页面看活动
            $action->action();
        }
    }else{// 主页面看活动
        $action->action();
    }
}else{
    $action->action();
}
*/